package com.cq.hd.common.enums.biz;

import lombok.Getter;

/**
 * @description: 支付状态(1-待支付,2-支付成功，3-支付失败，4-支付中)
 * @author: mYunYu
 * @date: 2021/8/23 14:28
 * @version: v1.0
 */
public enum PayStateEnum {

    WAIT(1, "待支付"),
    SUCCESS(2, "支付成功"),
    FAIL(3, "支付失败"),
    PAYING(4, "支付中"),
    ;

    @Getter
    private final Integer value;

    @Getter
    private final String name;

    PayStateEnum(Integer value, String name) {
        this.value = value;
        this.name = name;
    }

    public static PayStateEnum typeOf(Integer value) {
        PayStateEnum[] values = PayStateEnum.values();
        for (PayStateEnum v : values) {
            if (v.value.equals(value)) {
                return v;
            }
        }
        return null;
    }

    public static PayStateEnum typeOf(String name) {
        PayStateEnum[] values = PayStateEnum.values();
        for (PayStateEnum v : values) {
            if (v.name.equals(name)) {
                return v;
            }
        }
        return null;
    }

}
